package org.example.ymcc.feignclient.fallback;

import feign.hystrix.FallbackFactory;
import org.example.ymcc.feignclient.CourseFeignClient;
import org.example.ymcc.result.JsonResult;
import org.springframework.stereotype.Component;

@Component
public class CourseFeignClientFallbackFactory implements FallbackFactory<CourseFeignClient> {
    @Override
    public CourseFeignClient create(Throwable throwable) {
        return new CourseFeignClient() {
            @Override
            public JsonResult record(Long loginId, Long courseId) {
                return JsonResult.error(throwable.getMessage());
            }
        };
    }
}
